import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CacheUtil {
  static Widget cacheImage(String url,
      {double height, double width, BoxFit fit}) {
    Widget image;
    if (url.startsWith('http')) {
      image = CachedNetworkImage(
        imageUrl: url,
        height: height,
        width: width,
        fit: fit,
        // imageBuilder: (_, imageProvider) {},

        progressIndicatorBuilder: (_, url, progress) {
          return Container(
            width: 120.w,
            child: Center(
              child: CupertinoActivityIndicator(),
            ),
          );
        },
      );
    } else {
      image = Image.asset(
        url,
        height: height,
        width: width,
        fit: fit,
      );
    }
    return image;
  }
}
